<template>
  <div>
    <div class="all_msgBox" v-for="(list,index) in orderData" :key="index">

      <div class="mes_titleBox">
        <div class="idBox">
         <span>订单编号: {{list.orderId}}</span>
          <br>
          <span>总价格: ￥ {{list.goodsTotalPrice}}</span>
            <br>
          <span>商品数量: 共 {{list.goodsNum}} 件 </span>
            <br>
             <span>支付方式:  {{list.payWay}}  </span>
            <br>
          <span>订单创建时间: {{list.createTime}}</span>
          <br>
          <span>订单付款时间: {{list.checkTime}}</span>
           <div class="addressInfo">
             <p>配送信息：</p>
            <p>{{list.userName}}</p>
            <p>{{list.userPhone}}</p>
            <p>{{list.addressInfo}}{{list.addressDetailInfo}}</p>
          </div>
        </div>
        <!-- <div class="odrderStatusbox">
          <span>未支付</span>
        </div> -->
          <div class="contentButtonBox">
           <el-button class="btn_content" @click="orderClickPay(list.orderId)" :loading="checkLoading">
              继续支付 </el-button>
           <p class="btn_refund" @click="cancelOrder(list.orderId)">取消订单</p>
        </div>
      </div>
      <div class="contentBox">
         <div class="goodsdetailinfo" v-for=" ise,index in list.orderDetails" :key="index">
          <div class="goodsPic">
              <img class="goodsPic_img" :src="'/static/gd/'+ise.goodsPic" alt="">
          </div>
          <div class="contentPic">
            <p>{{ise.goodsname}}</p>
            <p>商品参数: {{ise.goodssize}} </p>
             <p>颜色: {{ise.goodscolor}} </p>
            <!-- <p>订单时间：2023/5/11</p> -->
            <p>价格：¥ {{ise.goodsprice}}</p>
            <p>共 {{ise.goodsnum}} 件</p>
            
          </div>
        </div>
       
      </div>
    </div>
  </div>
</template>

<script>
export default {
   inject: [
    "MyMessage","reload"
  ],
  name: 'orderChecked', //待付款
  data () {
    return {
      msg: '',
      orderData: [],
      checkLoading:false,
    }
  },
  methods: {
    //updateOrder

    orderClickPay(num){ //继续支付订单
      this.checkLoading = true;
      setTimeout(() => {
        localStorage.setItem("orderId",num);
        this.$router.push({
                name:'billpage',
                params:{}  //需要获取一个userId
              });
        this.checkLoading = false;
      }, 2000);
     
      //  this.MyMessage("测试"+num);
    },

    cancelOrder(orderId){
       let formData = {
        orderId:orderId,
        orderStatus:5
      }
      this.$axios.post('/g-order/changeOrder', formData)
      .then(res => {
        if(res.data.data){
          this.MyMessage("订单已取消");
          this.reload();
        }else{
          this.MyMessage("订单异常");
          this.reload();
        }
      })
    },



    queryOrderList(){
       let formData = {
        userId:localStorage.userId
      }
       this.$axios.post('/g-order/getOrderUserPage', formData)
      .then(res => {
        console.log(res.data.data);
        if(res.data.data){
          const data = res.data.data
          console.log(data);
          this.orderData = data.filter(item => item.orderStatus == 0);
        }else{
          console.log("获取订单数据失败");
        }
        
      })
    },
  },
  mounted () {
    this.queryOrderList();
  }
}
</script>

<style scoped>
li{
  list-style-type: none;
}
h1, h2, h3, h4, h5, h6,a,
div,p,fieldset,legend,span{
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    vertical-align: baseline;
}
.all_msgBox{
  position: relative;
  top: -20px;
  font-family: "Helvetica Neue", Helvetica, Arial, PingFang, "Microsoft YaHei", 雅黑体, SimHei, sans-serif;
  color: rgb(3, 3, 3);
  border-bottom: 10px solid gainsboro;
  /* display: none; */
  margin-top: 10px;
}
.mes_titleBox{
  width: 100%;
  /* height: 30px; */
  /* border: 1px solid rgb(25, 169, 140); */
  margin-bottom: 3px;
  display: flex;
}
.idBox{
  left: 0;
  width:90%;
       font-size: 13px;
    line-height: 18px;
    font-weight: 400;
    letter-spacing: .5px;
  color: rgb(110, 109, 109);
}
.odrderStatusbox{
  position: relative;
  /* width:30%; */
  font-weight: bold;
}

.contentBox{
  position: relative;
  width: 600px;
  height: auto;
  /* border: 1px solid rgb(219, 22, 22); */
  padding: 3px;
  display: flex;
  flex-wrap: wrap;
}

.goodsPic_img{
  width: 150px;
}
.contentPic{
  margin-left: 10px;
  /* width: 50%; */
  /* color: rgb(110, 109, 109); */
  /* font-size: 15px; */
      font-size: 13px;
    line-height: 18px;
    font-weight: 400;
    letter-spacing: .5px;
    font-family: AdihausDIN,PingFang SC,sans-serif,微软雅黑;
    font-style: normal;
    color: #000;
}
.contentButtonBox{
  margin: 0 auto;
}
.btn_content{
    margin-left:80px;
    min-height: 60px;
    min-width: 100px;
    border-radius: 50px;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    background: #111;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: .2s;
}
.btn_content:hover{
    background: rgb(47, 44, 44);
    color: rgb(255, 254, 254);
}
.addressInfo{
  margin-bottom: 10px;
  margin-top: 10px;
}
.btn_refund{
  width: 60px;
   top: 20px;
   left: 100px;
  cursor: pointer;
    font-family: AdihausDIN,PingFang SC,sans-serif,微软雅黑;
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 18px;
    letter-spacing: 1px;
    color: #000;
    border-bottom: 1px solid #000;
    position: relative;
}
.btn_refund:hover{
   color: #838080;
}
</style>
